<?php
   require("../../configuracion.php");
   $idSysSection = $sectionCampEmail;
   $path = "../../";
   require("../../application-top.php");

   require("email_programado_functions.php");
?>



<html>
<head>
  <title><?= $instanciaECRM ?></title>
  <link rel="stylesheet" href="../../styles/style.css" type="text/css">
  <script type="text/javascript" src="../../scripts/dynlayer.js"></script>
</head>
<body leftmargin="0" class="mainBackground" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr><td><img src="../../images/headerBar.gif" width="590" height="60" alt=""></td></tr>
  <tr>
    <td><table width="800" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#FFFFFF" valign="top" height="400">

<form name="forma">
<table border="0" cellpadding="5" cellspacing="0" width="750">
  <tr><td colspan="2"><table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr><td colspan="2"><img src="images/spacer.gif" height="10" width="1" alt=""></td></tr><tr><td><strong class="pageTitle">Campa&ntilde;as E-mail</strong><br><strong class="pageSubtitle">Programaci&oacute;n autom&aacute;tica</strong></td><td align="right"><a href="http://www.cacto.com/" target="_blank"><img src="../../images/trademarkCacto.gif" alt="Cacto" border="0"></a><br>
<strong class="systemTitle"><?= $instanciaECRM ?></strong><br>Perfil <strong><?= $PerfilUsuario ?></strong></td></tr>
  </table></td></tr>
  <tr><td>
    <table border="0" cellpadding="5" cellspacing="1" class="mainTableBG">
      <tr class="answerCellBG">
        <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
        <td><a href="email_admin.php" target="content">Regresar</a></td>
      </tr>
    </table>
  </td></tr>
 <tr><td>
    <table border="0" cellpadding="5" cellspacing="1" class="mainTableBG">
      <tr class="answerCellBG">
        <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
        <td><a href="email_enviados.php" target="content">Enviadas</a></td>
        <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
        <td class="titleBarTable">Programaci&oacute;n autom&aacute;tica</td>
        <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
        <td><a href="email_porenviar.php" target="content">Por enviar</a></td>
        <td><img src="../../images/icArrowGo.gif" height="13" width="13" alt=""></td>
        <td><a href="email_new.php" target="content">Crear nueva campa&ntilde;a</a></td>
      </tr>
    </table>
  </td></tr>
  <tr>
  <td valign="top" width="100%">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
      <td align="right">
        <table border="0" cellpadding="5" cellspacing="1" class="mainTableBG">
          <tr><td colspan="2"><strong class="mainTableTitle">B&uacute;squeda de correos de Programaci&oacute;n autom&aacute;tica</strong></td></tr>
               <tr class="answerCellBG">
            <td align="center" colspan="2">
                            <form name="busq1" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
              <input type="text" name="buscar" value="<?= $buscar ?>">
              <input type="hidden" name="action" value="buscar">
                            <input type="hidden" name="n_row" value="<?= $n_row ?>">
              <select name="id_Usuario_Elaboro">
                <option value="0">-- Seleccione elaborado por --</option>
<?php
    $query = "select id_SysUser,ltrim(nombre) + ' ' + ltrim(paterno) + ' ' + ltrim(materno) as NombreCompleto from app_SysUsers;";
    $result = mssql_query ($query);
    while ($row = mssql_fetch_object($result)){
      if ($id_Usuario_Elaboro == $row->id_SysUser){
        print "<option value=\"" . $row->id_SysUser . "\" selected>" . $row->NombreCompleto . "</option>\n";
      }
      else {
        print "<option value=\"" . $row->id_SysUser . "\">" . $row->NombreCompleto . "</option>\n";
      }
    }
?>
              </select>
            </td>
            <td><INPUT TYPE=IMAGE NAME="imagen" src="../../images/icBuscar.gif"></td>
          </tr>
                     </form>

        </table>
      </td>
      </tr>
      <tr><td><img src="../../images/spacer.gif" height="10" width="1" alt=""></td></tr>
      <tr><td colspan="2">
        <table border="0" cellpadding="5" cellspacing="1" width="100%" class="secTableBG">
          <tr class="answerCellBG"><td colspan="6" align="right">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
              <tr>
                              <form method="POST" action="<?= $_SERVER['PHP_SELF'] ?>">
                <td>Mostrar
                                  <select name="n_row">
<?
                                $registros[0] = "10";
                                $registros[1] = "25";
                                $registros[2] = "50";
                                $registros[3] = "100";
                                foreach($registros as $n){
                                  if ($n == $n_row){
                                    print "<option value=\"" . $n . "\" selected>" . $n . "</option>\n";
                                  }
                                  else {
                                    print "<option value=\"" . $n . "\">" . $n . "</option>\n";
                                  }
                                }
?>
                                  </select>
                                 <input type="hidden" name="action" value="<?= $action ?>">
                                 <input type="hidden" name="buscar" value="<?= $buscar ?>">
                                 <input type="hidden" name="id_Usuario_Elaboro" value="<?= $id_Usuario_Elaboro ?>">
                                 <input type="hidden" name="order" value="<?= $order ?>">
                                 <INPUT TYPE=IMAGE NAME="imagen" src="../../images/icArrowGo.gif">
                                </td>
                                 </form>
<?php

  $total_registros = total_registros($query_buscar);
  $n_paginas = ceil($total_registros / $n_row);
  $query = Paginar($pag,$n_row,$order,$query_buscar,$total_registros,$col_order);
?>
                <td align="right"><? paginas($pag,$n_paginas,$liga1) ?></td>
              </tr>
            </table>
          </td></tr>
          <tr>
            <td width="20%"><table border="0" cellpadding="2" cellspacing="0">
              <tr>
                <td width="100%" class="secTableTitle"><strong>Campa&ntilde;a&nbsp;E-mail</strong></td>
                                 <? $liga = $_SERVER['PHP_SELF'] . "?order=asc&col_order=st_NombreCampaniaEmail"; ?>
                <td><a href="<?= $liga . $liga1 ?>"><img src="../../images/icSortAsc.gif" height="12" width="13" alt="Orden Ascendente" border="0"></a></td>
                                 <? $liga = $_SERVER['PHP_SELF'] . "?order=desc&col_order=st_NombreCampaniaEmail"; ?>
                <td><a href="<?= $liga . $liga1 ?>"><img src="../../images/icSortDesc.gif" height="12" width="13" alt="Orden Descendente" border="0"></a></td>
              </tr>
            </table></td>
            <td width="20%"><table border="0" cellpadding="2" cellspacing="0">
              <tr>
                <td width="100%" class="secTableTitle"><strong>Frecuencia</strong></td>
                                <? $liga = $_SERVER['PHP_SELF'] . "?order=asc&col_order=i_TipoRepeticion"; ?>
                <td><a href="<?= $liga . $liga1 ?>"><img src="../../images/icSortAsc.gif" height="12" width="13" alt="Orden Ascendente" border="0"></a></td>
                                <? $liga = $_SERVER['PHP_SELF'] . "?order=desc&col_order=i_TipoRepeticion"; ?>
                <td><a href="<?= $liga . $liga1 ?>"><img src="../../images/icSortDesc.gif" height="12" width="13" alt="Orden Descendente" border="0"></a></td>
              </tr>
            </table></td>
            <td width="20%">
			<table border="0" cellpadding="2" cellspacing="0">
              <tr>
                <td width="100%" class="secTableTitle"><strong>Status</strong></td>
                                <? $liga = $_SERVER['PHP_SELF'] . "?order=asc&col_order=i_Activo"; ?>
                <td><a href="<?= $liga . $liga1 ?>"><img src="../../images/icSortAsc.gif" height="12" width="13" alt="Orden Ascendente" border="0"></a></td>
                                 <? $liga = $_SERVER['PHP_SELF'] . "?order=desc&col_order=i_Activo"; ?>
                <td><a href="<?= $liga . $liga1 ?>"><img src="../../images/icSortDesc.gif" height="12" width="13" alt="Orden Descendente" border="0"></a></td>
              </tr>
            </table></td>			
            <td width="20%"><table border="0" cellpadding="2" cellspacing="0">
              <tr>
                <td width="100%" class="secTableTitle"><strong>Elaborado por</strong></td>
                                <? $liga = $_SERVER['PHP_SELF'] . "?order=asc&col_order=Elaboro"; ?>
                <td><a href="<?= $liga . $liga1 ?>"><img src="../../images/icSortAsc.gif" height="12" width="13" alt="Orden Ascendente" border="0"></a></td>
                                 <? $liga = $_SERVER['PHP_SELF'] . "?order=desc&col_order=Elaboro"; ?>
                <td><a href="<?= $liga . $liga1 ?>"><img src="../../images/icSortDesc.gif" height="12" width="13" alt="Orden Descendente" border="0"></a></td>
              </tr>
            </table></td>
          </tr>
     
     
<?php
 
  $i = 0;
  $result = mssql_query ($query);
  while ($row = mssql_fetch_object($result)):

  $i_TipoRepeticion = $row->i_TipoFrecuencia;
  if ($i_TipoRepeticion == "1" ){
    $TipoRepeticion = "Diario";
  }
  else if ($i_TipoRepeticion == "2" ){
    $TipoRepeticion = "Semanal";
  }
  else if (($i_TipoRepeticion == "3" ) or ($i_TipoRepeticion == "4" )){
    $TipoRepeticion = "Mensual";
  }
  else if ($i_TipoRepeticion == "5" ){
    $TipoRepeticion = "Anual";
  }

  if ($row->i_Activo == 1){
    $Activo = "Activa";
  }
  else{
    $Activo = "Inactiva";
  }

  if ($row->i_Status == 1){
    $Status = $Activo. " (Autorizada)";
  }
  else{
    $Status = "Pendiente";
  }

  if ($i == 0){
     $_class="conceptCellBG";
     $i = 1;
  }
  else {
     $_class = "answerCellBG";
     $i = 0;
  }
  ?>
          <tr class="<?= $_class ?>">
            <td width="30%"><a href="email_detalleprogramado.php?id_Campania=<?= $row->id_CampaniaEmail?>" target="content"><?= $row->st_NombreCampaniaEmail ?></a></td>
            <td width="20%"><?= $TipoRepeticion?></td>
            <td width="20%"><?= $row->st_StatusCampania ?></td>
            <td width="30%"><?= $row->Elaboro ?></td>
      
          </tr>
<? endwhile ?>
          <tr class="answerCellBG">
                    <td colspan="6" align="right"><? paginas($pag,$n_paginas,$liga1) ?></td></tr>
        </table>
      </td></tr>
    </table>
  </td>
  </tr>
</table>
          </td>
        </tr>
      </table></td>
  </tr>
</table>
</form>
<br>
<br>
<br>
<table width="750" border="0">
  <tr>
    <td align="right"><span class="copyright"><?= $copyright ?></span></td>
  </tr>
</table>
</body>
</html>
